
#include	<math.h>
#include "Ucamera/Pt2dType.h"

#include	"ImageType/ImageType.h"
#include	"ImageF/ImageFTool.h"

#include	"Interpolation.h"


static float	interpolaton_value( float x, float y, pt2dA_type *apt );



image_type *
imageF_interpolation_1( int width, int height, pt2dA_type *apt, image_type *im )
{
float	*tp;
float	tmp;
int	i,	j;
float	x,	y;

	im = image_alloc( width, height, 1, IMAGE_TYPE_F, 1 );


	

	tp =im->data_f;

	for( i = 0 ; i < im->row ; i++ ){
		y = i + 0.5;
		for( j = 0 ; j < im->column ; j++, tp++ ){
			x = j + 0.5;


			tmp = interpolaton_value( x, y, apt );

			*tp = tmp;
		}
	}


	return( im );
}

static float 
interpolaton_value( float x, float y, pt2dA_type *apt )
{
pt2d_type	*pt;
vec2f_type	dv;
float	d,	val;

	pt = &apt->p[0];

	dv.x = x- pt->p.x;
	dv.y = y - pt->p.y;

	d = dv.x*dv.x + dv.y * dv.y;

	if( d < 200*200 ){
		val = 1 - d /( 200*200) ;
	}
	else	val = 0;

	return( val );

}